package com.leo.ui;

import com.almasb.fxgl.app.scene.LoadingScene;
import com.almasb.fxgl.core.math.FXGLMath;
import javafx.animation.Animation;
import javafx.animation.FillTransition;
import javafx.scene.shape.Circle;
import javafx.util.Duration;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-13  23:03
 * @Description: TODO
 */
public class TestLoadingScene extends LoadingScene {

    private final FillTransition ft;

    public TestLoadingScene() {
        Circle circle = new Circle(100, FXGLMath.randomColor());
        circle.setTranslateX(200);
        circle.setTranslateY(300);
        ft = new FillTransition(Duration.seconds(1), circle);
        ft.setFromValue(FXGLMath.randomColor());
        ft.setToValue(FXGLMath.randomColor());
        ft.setCycleCount(Animation.INDEFINITE);
        ft.play();
        getContentRoot().getChildren().add(circle);
    }

    @Override
    public void onCreate() {
        ft.play();
    }

    @Override
    public void onDestroy() {
        ft.stop();
    }
}
